/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FINANCE_INNERKITS_IKEYBOARD_SRV_H
#define FINANCE_INNERKITS_IKEYBOARD_SRV_H

#include <string>
#include "iremote_broker.h"
#include "iremote_object.h"
#include "keyboard_def.h"
#include "icashdevice_srv.h"

namespace SwanLink {
namespace Finance {
using namespace OHOS;
class IKeyboardSrv : public SwanLink::Finance::ICashDeviceSrv {
 public:
    enum {
        KEYBOARD_ISSM4ENABLED = CASHDEBICE_OTHER,
        KEYBOARD_GETSN,
        KEYBOARD_CALCULATEMAC,
        KEYBOARD_ENCRYPTDATA,
        KEYBOARD_SETPINLENGTH,
        KEYBOARD_SETTEXTMODE,
        KEYBOARD_CLEARTEXTMODE,
        KEYBOARD_LOADMASTERKEY,
        KEYBOARD_LOADUSERKEY,
        KEYBOARD_UPDATEMASTERKEY,
        KEYBOARD_UPDATEUSERKEY,
        KEYBOARD_DELETEUSERKEY,
        KEYBOARD_LISTENFORPIN,
    };
	/**
	 * 是否使用国密
	 */
    virtual bool IsSM4Enabled(int handle) = 0;
	/**
	 * 获取密码键盘序列号
	 */
    virtual int GetSN(int handle, char sn[], int &len) = 0;
	/**
	 * 计算MAC
	 */
    virtual int CalculateMAC(int handle, const KeyInfo& key, char plain[], int len, char enc_data[], int &enc_len) = 0;
	/**
	 * 加密数据
	 */
    virtual int EncryptData(int handle, const KeyInfo& key, char plain[], int len, char enc_data[], int &len_enc) = 0;
	/**
	 * 设置PIN的长度限制
	 */
    virtual int SetPINLength(int handle, int minLen, int maxLen) = 0;
	/**
	 * 获取错误信息
	 */
    virtual int SetTextMode(int handle, TextMode mode) = 0;
	/**
	 * 清空文本
	 */
    virtual void ClearTextMode(int handle) = 0;
	/**
	 * 加载主密钥
	 */
    virtual int LoadMasterKey(int handle, KeyID masterKeyID, unsigned char *KeyValue) = 0;
	/**
	 * 加载用户密钥
	 */
    virtual int LoadUserKey(int handle, KeyID masterKeyID, userKeyType user_Key_Type, unsigned char *KeyValue) = 0;
	/**
	 * 更新密钥
	 */
    virtual int UpdateMasterKey(int handle, KeyID masterKeyID, unsigned char *KeyValue) = 0;
	/**
	 * 更新用户密钥
	 */
    virtual int UpdateUserKey(int handle, KeyID masterKeyID, userKeyType user_Key_Type, unsigned char *KeyValue) = 0;
	/**
	 * 删除用户密钥
	 */
    virtual int DeleteUserKey(int handle, KeyID masterKeyID, userKeyType user_Key_Type) = 0;
	/**
	 * 监听
	 */
    virtual void ListenForPin(int handle, PinListener* listener, int timeout) = 0;

    DECLARE_INTERFACE_DESCRIPTOR(u"ohos.Finance.IKeyboardSrv");
};
} // namespace Finance
} // namespace SwanLink

#endif // FINANCE_INNERKITS_IKEYBOARD_SRV_H
